View Javadoc

1   /*
2    * Copyright (c) 2004-2005, University Health Network.  All rights reserved. Distributed under the BSD 
3    * license (see http://opensource.org/licenses/bsd-license.php).
4    *  
5    * IChunkStorage.java
6    *
7    * Created on 2-Dec-2004 at 5:29:25 PM
8    */
9   package ca.uhn.cache.internal;
10  
11  import ca.uhn.cache.IQuery;
12  import ca.uhn.cache.CacheReasonEnum;
13  import ca.uhn.cache.VolatilityEnum;
14  
15  /***
16   * A Map like interface to store <code>IChunk</code>s. 
17   * 
18   * @author <a href="mailto:alexei.guevara@uhn.on.ca">Alexei Guevara</a>
19   * @version $Revision: 1.1 $ updated on $Date: 2005/01/24 22:53:27 $ by $Author: bryan_tripp $
20   */
21  public interface IChunkStore {
22      
23      /***
24       * @param theQuery The specified query.
25       * @return The value to which this <code>IChunkStore</code> maps the specified query, or
26       *         <tt>null</tt> if the <code>IChunkStore</code> contains no mapping for the query. 
27       */
28      public IChunk get( IQuery theQuery );
29  
30      /***
31       * Places a <code>IChunk</code> corresponding to the specified <code>IQuery</code>
32       * in this <code>IChunkStore</code>.  If the <code>IChunkStore</code> previously contained 
33       * a mapping for this query, the value is replaced by a new <code>IChunk</code> with the new volatility
34       * and reasons.
35       *  
36       * @param theQuery Query with which the chunk is to be associated.
37       * @param theVolatility The volatility that will decide the length of stay in the cache. If there
38       * is a mapping for this query currently in the cache, this will replace the old value. 
39       * @param theReasons The reasons that this chunk was cached. If there is a mapping for this query
40       * currently in the cache, this will be appended to the old value.
41       * 
42       * @return Previous value associated with specified query, or <tt>null</tt>
43       *         if there was no mapping for the query.
44       */    
45      public IChunk put( IQuery theQuery, VolatilityEnum theVolatility, CacheReasonEnum[] theReasons );
46      
47      /***
48       * Removes the mapping for this query from this <code>IChunkStore</code> if it is present 
49       * 
50       * @param theQuery Query whose mapping is to be removed from the <code>IChunkStore</code>.
51       * 
52       * @return Previous value associated with specified query, or <tt>null</tt>
53       *         if there was no mapping for the query.
54       */
55      public IChunk remove( IQuery theQuery );
56      
57      /***
58       * @return Returns the rule used to determine when chunks will expire. 
59       */
60      public IStaleChunkRule getStaleChunkRule();
61      
62  }